package org.nyt.medicalstore.controller;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("")
@CrossOrigin(origins = "*")
public class HealthController {

    @GetMapping("/health")
    public ResponseEntity<?> health() {
        Map<String, Object> response = new HashMap<>();
        response.put("status", "UP");
        response.put("timestamp", LocalDateTime.now());
        response.put("service", "medicalstore-api");
        response.put("version", "1.0.0");
        return ResponseEntity.ok(response);
    }

    @GetMapping("/")
    public ResponseEntity<?> root() {
        Map<String, Object> response = new HashMap<>();
        response.put("message", "医药管理系统 API");
        response.put("version", "1.0.0");
        response.put("timestamp", LocalDateTime.now());
        response.put("endpoints", new String[]{
            "/health - 健康检查",
            "/drugs - 药品管理",
            "/inventories - 库存管理", 
            "/sale-records - 销售记录",
            "/auth - 用户认证"
        });
        return ResponseEntity.ok(response);
    }

    @GetMapping("/info")
    public ResponseEntity<?> info() {
        Map<String, Object> response = new HashMap<>();
        response.put("app", "Medical Store Management System");
        response.put("version", "1.0.0");
        response.put("java_version", System.getProperty("java.version"));
        response.put("server_time", LocalDateTime.now());
        return ResponseEntity.ok(response);
    }
} 